#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll INF = 1e12;

struct Node {
	ll l;
	ll r;
	ll val;
	Node friend operator + (Node x, Node y) {
		Node z;
		z.l = min(x.l, y.l);
		z.r = max(x.r, y.r);
		z.val = min(y.l - x.r, min(x.val, y.val));
		return z;
	}
} tr[4001000];

ll T, n;
multiset<ll> st1, st2;
multiset<ll> s1[1001000], s2[1001000];
char c[110];

void build(ll l, ll r, ll idx) {
	if (l == r) {
		tr[idx].l = INF;
		tr[idx].r = -INF;
		tr[idx].val = INF;
	} else {
		ll mid = (l + r) >> 1;
		build(l, mid, idx << 1);
		build(mid + 1, r, idx << 1 | 1);
		tr[idx] = tr[idx << 1] + tr[idx << 1 | 1];
	}
	return;
}

void upd1(ll l, ll r, ll idx, ll x, ll y) {
	if (l == r) {
		if (y > 0) {
			s1[x].insert(y);
		} else {
			s1[x].erase(s1[x].lower_bound(-y));
		}
		ll xx = INF;
		ll yy = -INF;
		if (!s1[x].empty()) {
			xx = (*s1[x].begin());
		}
		if (!s2[x].empty()) {
			yy = (*s2[x].rbegin());
		}
		tr[idx].l = xx;
		tr[idx].r = yy;
		tr[idx].val = xx - yy;
	} else {
		ll mid = (l + r) >> 1;
		if (x <= mid) {
			upd1(l, mid, idx << 1, x, y);
		} else {
			upd1(mid + 1, r, idx << 1 | 1, x, y);
		}
		tr[idx] = tr[idx << 1] + tr[idx << 1 | 1];
	}
	return;
}

void upd2(ll l, ll r, ll idx, ll x, ll y) {
	if (l == r) {
		if (y > 0) {
			s2[x].insert(y);
		} else {
			s2[x].erase(s2[x].lower_bound(-y));
		}
		ll xx = INF;
		ll yy = -INF;
		if (!s1[x].empty()) {
			xx = (*s1[x].begin());
		}
		if (!s2[x].empty()) {
			yy = (*s2[x].rbegin());
		}
		tr[idx].l = xx;
		tr[idx].r = yy;
		tr[idx].val = xx - yy;
	} else {
		ll mid = (l + r) >> 1;
		if (x <= mid) {
			upd2(l, mid, idx << 1, x, y);
		} else {
			upd2(mid + 1, r, idx << 1 | 1, x, y);
		}
		tr[idx] = tr[idx << 1] + tr[idx << 1 | 1];
	}
	return;
}

int main() {
	freopen("stone.in", "r", stdin);
	freopen("stone.out", "w", stdout);
	n = 1e6;
	scanf("%lld", &T);
	build(1, n, 1);
	while (T--) {
		ll x, y;
		scanf("%s", c + 1);
		scanf("%lld%lld", &x, &y);
		if (c[1] == 'A') {
			st1.insert(x);
			st2.insert(y);
			upd1(1, n, 1, x, y);
			upd2(1, n, 1, y, x);
		} else {
			st1.erase(st1.lower_bound(x));
			st2.erase(st2.lower_bound(y));
			upd1(1, n, 1, x, -y);
			upd2(1, n, 1, y, -x);
		}
		if (tr[1].val > n) {
			ll xx = (*st1.rbegin());
			ll yy = (*st2.begin());
			printf("%lld\n", (*s1[xx].begin()) - (*s2[yy].rbegin()));
		} else {
			printf("%lld\n", tr[1].val);
		}
	}
	return 0;
}
